package org.colafries.admin.controller.index;

import org.colafries.admin.controller.BaseController;
import org.colafries.admin.entity.domain.index.LogicDimRelation;
import org.colafries.admin.entity.domain.index.LogicDimension;
import org.colafries.admin.entity.vo.index.LogicDimRelationReqVO;
import org.colafries.admin.entity.vo.index.LogicDimensionReqVO;
import org.colafries.admin.service.index.ILogicDimRelationService;
import org.colafries.admin.service.index.ILogicDimensionService;
import org.colafries.admin.wrapper.Response;
import org.colafries.admin.wrapper.ResponseWrapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Ann
 * @version v1.0
 * @ClassName LogicDimensionController
 * @Description
 * @date Created in 2024/6/13
 **/
@RestController
@RequestMapping("/index/logicDimension")
public class LogicDimensionController extends BaseController<ILogicDimensionService, LogicDimension, LogicDimensionReqVO> {
    @Resource
    ILogicDimRelationService iLogicDimRelationService;
    @Override
    protected String getServiceName() {
        return "ILogicDimensionServiceImpl";
    }

    /**
     * 新增逻辑维度关系
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/14
     */
    @PostMapping("/addDimRelation")
    public Response<?> addDimRelation(@RequestBody LogicDimRelationReqVO reqVO) {
        int result = iLogicDimRelationService.add(reqVO);
        return ResponseWrapper.ok(result);
    }
    @PostMapping("/listAllDimRelation")
    public Response<?> listAllDimRelation(@RequestBody LogicDimRelationReqVO reqVO) {
        List<LogicDimRelation> result = iLogicDimRelationService.listAll(reqVO);
        return ResponseWrapper.ok(result);
    }


    /**
     * 修改逻辑关系
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/14
     */
    @PostMapping("/updateDimRelation")
    public Response<?> updateDimRelation(@RequestBody LogicDimRelationReqVO reqVO) {
        int result = iLogicDimRelationService.update(reqVO);
        return ResponseWrapper.ok(result);
    }

    /**
     * 删除逻辑关系
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/14
     */
    @PostMapping("/deleteDimRelation")
    public Response<?> deleteDimRelation(@RequestBody LogicDimRelationReqVO reqVO) {
        int result = iLogicDimRelationService.delete(reqVO);
        return ResponseWrapper.ok(result);
    }
}
